package com.goldcn.user.dao;

import com.goldcn.user.dto.StateDto;
import com.goldcn.user.dto.UserQtyCountDto;
import com.goldcn.user.dto.UserSelectDto;
import com.goldcn.user.model.UserInfo;
import com.goldcn.user.vo.UserCountVo;
import com.goldcn.user.vo.UserInfoVo;
import com.goldcn.user.vo.UserOrganizationalInfoVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Component
public interface UserInfoMapper {
    int deleteByPrimaryKey(Long userID);

    int insert(UserInfo record);

    int insertSelective(UserInfo record);

    UserInfo selectByPrimaryKey(Long userID);

    int updateByPrimaryKeySelective(UserInfo record);

    int updateByPrimaryKey(UserInfo record);

    List<UserInfo> selectByOID(Long oID);

    List<UserInfo> selectEmployeeByOID(Long oID);

    int deleteByOID(Long oID);

    int updateIsStop(StateDto stateDto);

    UserInfo selectRecommenderPhone(@Param(value = "phone") String phone, @Param(value = "companyID") Long companyID);

    List<UserInfoVo> selectByCondition(UserSelectDto selectDto);

    List<UserInfoVo> selectByCondition2(UserSelectDto selectDto);

    int updateToConsultant(Map<String, Object> params);

    List<UserInfo> selectByPhone(@Param(value = "mobile") String mobile, @Param(value = "companyID") Long companyID);

    List<UserInfo> selectByAccount2(@Param(value = "account") String account, @Param(value = "companyID") Long companyID);

    UserInfo selectByAccount(@Param(value = "account") String account, @Param(value = "companyID") Long companyID);

    int selectUserQtyByCondition(UserQtyCountDto userQtyCountDto);

    List<Long> selectConsultantIDByManagerID(Long paterID);

    List<UserCountVo> selectUserQtyByPaterID(List<Long> paterIDList);

    Integer selectQtyByEmployeeIsAudit(UserOrganizationalInfoVo info);

    UserInfo selectByRecommendNO(@Param(value = "recommendNO") Integer recommendNO, @Param(value = "companyID") Long companyID);

    List<Map<String,Object>> selectMobileByUserIDList(List<Long> userIDList);

    //TODO 管理者
    Long selectAdminIDByOID(Long oID);

    //create by zll 2017/4/11
    List<Map<String,Object>> selectUserInfoListByIds(List<Long> userIdList);
    List<Map<String,Object>> getOrderCountUserInfo(Long companyID);
    List<UserInfo> selectByLikeName(@Param(value = "name") String name, @Param(value = "companyID") Long companyID);
    UserInfo getRecommendNoByPaterID(Long paterID);


    /**
     * 统计员工激活数
     * 总部
     * @param oID
     * @return
     */
    Long countEmployeeActNum(@Param(value = "oID") Long oID, @Param(value = "companyID") Long companyID);

    /**
     * 统计总部(本部)员工激活数
     * @param oID
     * @return
     */
    Long countEmployeeActNumByoID(@Param(value = "oID") Long oID, @Param(value = "companyID") Long companyID);


    /**
     * 统计员工激活数
     * 分部
     * @param oID
     * @return
     */
    Long countEmployeeActNum_2(Long oID);

    /**
     * 统计员工激活数
     * 支部
     * @param oID
     * @return
     */
    Long countEmployeeActNum_3(Long oID);

    /**
     * 总部查看分部员工
     * @param level
     * @param branchID
     * @return
     */
    List<UserOrganizationalInfoVo> branchEmployee(
            @Param("level") Integer level, @Param("levelNext") Integer levelNext, @Param("branchID") Long branchID, @Param("companyID") Long companyID);

    /**
     * 分部查看二级分部员工
     * @param level
     * @param branchID
     * @return
     */
    List<UserOrganizationalInfoVo> branchEmployee_2(
            @Param("level") Integer level, @Param("levelNext") Integer levelNext, @Param("branchID") Long branchID);

    /**
     * 二级分部查看支部员工
     * @param level
     * @param branchID
     * @return
     */
    List<UserOrganizationalInfoVo> branchEmployee_3(
            @Param("level") Integer level, @Param("levelNext") Integer levelNext, @Param("branchID") Long branchID);

    /**
     * 总部查看分部会员
     * @param level
     * @param branchID
     * @return
     */
    List<UserOrganizationalInfoVo> branchMember(
            @Param("level") Integer level, @Param("levelNext") Integer levelNext, @Param("branchID") Long branchID);

    /**
     * 分部查看二级分部会员
     * @param level
     * @param branchID
     * @return
     */
    List<UserOrganizationalInfoVo> branchMember_2(
            @Param("level") Integer level, @Param("levelNext") Integer levelNext, @Param("branchID") Long branchID);

    /**
     * 二级分部查看支部会员
     * @param level
     * @param branchID
     * @return
     */
    List<UserOrganizationalInfoVo> branchMember_3(
            @Param("level") Integer level, @Param("levelNext") Integer levelNext, @Param("branchID") Long branchID);

    /**
     * 统计理财经理的会员注册数
     * @param paterID
     * @return
     */
    Long countMemberBySalesManager(Long paterID);


    /**
     * 查询理财经理的会员
     * @return
     */
    //List<UserInfoVo> selectUsersBySalesManager(memberVo memberVo);


    Map<String,BigDecimal> selectUserStatCount(Map<String, Object> map);


    Map<String,Object> getAllEmpAndMemCount(Long companyID);

    Map<String,Object> getEmpActCount();

    int updateStateByUserID(@Param("state") Integer state, @Param("userID") Long userID, @Param("lastTransferTime") Long lastTransferTime, @Param("extraSql") String extraSql);

    List<UserInfo> selectEmployee(@Param("keyword") String keyword, @Param("companyID") Long companyID);

    List<UserInfo> selAdminUser(@Param("companyID") Long companyID);

    List<UserInfo> selAppUser(@Param("companyID") Long companyID);

   /* 调度审核三天未审核的员工*/
    List<UserInfo> selectExpiredTransfer();

    List<UserInfo> selAllUser(@Param("companyID") Long companyID);

    Map<String,Object> selectPurchaserByUserID(Long userID);

    List<UserInfo> selectByPaterID(@Param("paterID") Long paterID);

    List<UserInfo> selectByType(Integer type);

    List<UserInfo> getUserByAccount(@Param("account") String account, @Param("type") Integer type, @Param("companyID") Long companyID);

    List<UserInfo> getShopManagerByShopID(@Param(value = "shopID") Long shopID);

    int updateEmployeeByShopID(@Param("shopID") Long shopID);
}
